from app.database.connections import db
import MySQLdb
import json



class Cpu(db.Model):
    id = db.Column(db.BigInteger, primary_key=True)
    mac_code = db.Column(db.String)
    cpu_name = db.Column(db.String)
    utilization = db.Column(db.Numeric)
    speed = db.Column(db.Numeric)
    processes = db.Column(db.Integer)
    threads = db.Column(db.Integer)
    handles = db.Column(db.Integer)
    uptimes = db.Column(db.DateTime)
    base_speed = db.Column(db.Numeric)
    slots = db.Column(db.Integer)
    kernels = db.Column(db.Integer)
    logical_processors = db.Column(db.Integer)
    # is_virtualization = db.Column(db.String)
    # l1_cache_size = db.Column(db.String)
    # l2_cache_size = db.Column(db.String)
    # l3_cache_size = db.Column(db.String)
    # create_user_id = db.Column(db.String)
    # create_time = db.Column(db.String)
    # update_user_id = db.Column(db.String)
    # update_time = db.Column(db.String)
    # yn = db.Column(db.String)

    def __init__(self,mac_code,cpu_name,utilization,speed,processes,threads,handles,uptimes,base_speed,slots,kernels,logical_processors):
        self.mac_code = mac_code
        self.cpu_name = cpu_name
        self.utilization = utilization
        self.speed = speed
        self.processes = processes
        self.threads = threads
        self.handles = handles
        self.uptimes = uptimes
        self.base_speed = base_speed
        self.slots = slots
        self.kernels = kernels
        self.logical_processors = logical_processors

    def __repr__(self):

        return '<cpu: %r,%r,%r,%r >' % (self.id , self.mac_code , self.cpu_name,self.utilization)